const Koa = require('koa')
const bodyParser = require('koa-bodyparser')
const response = require('../middleware/response')
const errorHandler = require('./error-handle')

// const userRouter = require('../router/user.router')
// const momentRouter = require('../router/moment.router')
// const commentRouter = require('../router/comment.router')
// const userinfoRouter = require('../router/userinfo.router')
// const fileRouter = require('../router/file.router')
const useRoutes = require('../router')

const app = new Koa()
app.use(bodyParser())
app.use(response)
// app.use(userRouter.routes())
// app.use(userRouter.allowedMethods())
// app.use(momentRouter.routes())
// app.use(momentRouter.allowedMethods())
// app.use(commentRouter.routes())
// app.use(commentRouter.allowedMethods())
// app.use(userinfoRouter.routes())
// app.use(userinfoRouter.allowedMethods())
// app.use(fileRouter.routes())
// app.use(fileRouter.allowedMethods())
app.useRoutes = useRoutes;
app.useRoutes()
app.on('error', errorHandler)

module.exports = app